<?php
/*
 * Created on Sep 4, 2009
 * @author Dang Thu Trang <trangdtdg@gmail.com>
 */
require_once APPPATH."controllers/cmsbase.php";
class cms_authentication extends CmsBase{
  function __construct() {
    parent:: __construct();
  }
  function login(){
    $error = null;
    if(isset($_POST['Submit']) && $_POST['Submit']){
      $result = $this->sys_model->findByUP($_POST['n'],$_POST['p']);
      if(!empty($result)){        
        $_SESSION['purplelog'] = "pa_akh12";
        $_SESSION[ADMINUSERLOGIN] = $result;
        redirect('cms_home');
      }
      else {
        $error = 'Password or Username<br> &quot;is not correct&quot;<br><br> please try again!';
      }
    }
    $this->main_content = $this->load->view('cms_authentication/login', $this->_mereg(array('error'=>$error)),true);
    $this->_render();
  }//login
  function logout(){
    // clear session
    $_SESSION = array();    
    redirect('cms_authentication/login');
  }
}
